package refleftiontestdome;


class Student {
    //私有属性name - 不能外部直接调用，除非设置set 和 get接口
    private String name = "author";
    //公有属性age
    public int age = 18;

    //不带参数的公有构造方法
    public Student() {
        System.out.println("Student()");
    }
    //带参数的私有构造方法 - 不能外部直接调用，除非设置set 和 get接口
    private Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Student(String,name)");
    }
    // 私有方法
    private void eat(){
        System.out.println("i am eat");
    }
    // 公有方法
    public void sleep(){
        System.out.println("i am pig");
    }
    // 私有方法
    private void function(String str) {
        System.out.println(str);
    }
    // 重写 toString 方法
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class TestDemo {
    public static void main(String[] args) {

        Class<?> c1 = null;
        try {
            c1 = Class.forName("refleftiontestdome.Student");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        Class<?> c2 =  Student.class;

        Student student = new Student();
        Class<?> c3 = student.getClass();

        System.out.println(c1 == c2);
        System.out.println(c1 == c3);
        System.out.println(c2 == c3);

    }
}
